// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.reports.editor.design.utils;

import org.eclipse.core.runtime.Platform;

/**
 * The utility class for tracing
 * 
 * /** Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf Qiang.Zhang.Adolf@gmail.com 2008-2-22 qiang.zhang $
 * 
 */
public class Policy {

    public static final boolean DEBUG = true;

    public static final boolean TRACING_ACTIONS = getDebugOption("actions"); //$NON-NLS-1$

    public static final boolean TRACING_COMMANDS = getDebugOption("commands"); //$NON-NLS-1$

    public static final boolean TRACING_DIALOGS = getDebugOption("dialogs"); //$NON-NLS-1$

    public static final boolean TRACING_DND_DRAG = getDebugOption("dnd.drag"); //$NON-NLS-1$

    public static final boolean TRACING_DND_DROP = getDebugOption("dnd.drop"); //$NON-NLS-1$

    public static final boolean TRACING_RULER = getDebugOption("ruler"); //$NON-NLS-1$

    public static final boolean TRACING_EXTENSION_LOAD = getDebugOption("extension.load"); //$NON-NLS-1$

    public static final boolean TRACING_EDITPART_CREATE = getDebugOption("editpart.create"); //$NON-NLS-1$

    public static final boolean TRACING_MENU_SHOW = getDebugOption("menu.show"); //$NON-NLS-1$

    public static final boolean TRACING_PAGE_CHANGE = getDebugOption("page.change"); //$NON-NLS-1$

    public static final boolean TRACING_PAGE_CLOSE = getDebugOption("page.close"); //$NON-NLS-1$	

    public static final boolean TRACING_DND = getDebugOption("dnd"); //$NON-NLS-1$

    /**
     * Returns the debug option with the given id
     * 
     * @param id the id of the debug option
     * @return the debug option,or false if the id doesn't exist.
     */
    public static boolean getDebugOption(String id) {
        boolean option = false;
        if (DEBUG) {
            option = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.birt.report.designer.ui/tracing/" //$NON-NLS-1$ //$NON-NLS-2$
                    + id));
        }
        return option;
    }

}
